﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PublishData.DAL;
namespace PublishData.BLL
{
    /// <summary>
    /// Admin toàn quyền
    /// VietBai không có chức năng duyệt bài
    /// </summary>
    public enum Quyen
    {
        Admin, VietBai
    }
    public class UserBLL
    {

        internal static void DoiMatKhau(DAL.User m_NguoiSuDung, string matKhauMoi, string tenNguoiDung)
        {
            using (var data = FormThietLapChuoiKetNoi.AppDbConnection)
            {
                var user = (from e in data.Users
                            where e.tenDangNhap == m_NguoiSuDung.tenDangNhap && e.matKhau == m_NguoiSuDung.matKhau
                            select e).SingleOrDefault();
                if (user != null)
                {
                    user.hoTen = tenNguoiDung;
                    user.matKhau = matKhauMoi;
                    data.SubmitChanges();
                }
            }
        }


        internal static DAL.User getNguoiSuDung(string tenDangNhap, string matKhau)
        {
            using (var data = FormThietLapChuoiKetNoi.AppDbConnection)
            {
                var user = (from e in data.Users
                            where e.tenDangNhap == tenDangNhap && e.matKhau == matKhau
                            select e).SingleOrDefault();
                return user;
            }
        }
    }
}
